package com.chanyachting.emall.action.businesstype;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.chanyachting.emall.domain.Businesstype;
import com.chanyachting.emall.form.BusinesstypeForm;
import com.chanyachting.emall.service.BusinesstypeService;
import com.chanyachting.emall.serviceImpl.BusinesstypeServiceImpl;
import com.chanyachting.emall.util.RequestUtil;

public class CreateAction extends Action {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		if(request.getMethod().equals("POST")){
			
			BusinesstypeForm btForm=(BusinesstypeForm)form;
			
			//调用验证
			if(btForm.validate(mapping, request).isEmpty()){
				
				Businesstype btype=new Businesstype();
				
				BeanUtils.copyProperties(btype, btForm);
				
				BusinesstypeService bs=new BusinesstypeServiceImpl();
				
				bs.addBusinesstype(btype);
				
				new RequestUtil(request).setSuccessMsg();
				
			}
		}

		return mapping.findForward("businesstypeCrate");
	}
	
	
	

}
